package com.wdy.po;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import com.wdy.util.BasicUtil;
@SuppressWarnings({"unchecked", "serial"})
public class Complaint implements Comparable, Serializable {

	private Integer coid;
	private String title;
	private Date date;
	private String content;
	private String dealState;
	private Date dealDate;
	private String transactor;
	private String note;
	private Set<Tenement> tenements;
	
	public Complaint() {
		super();
	}

	public Complaint(Integer coid, Date date, String content, String dealState,
			Date dealDate, String transactor, String note,
			Set<Tenement> tenements) {
		super();
		this.coid = coid;
		this.date = date;
		this.content = content;
		this.dealState = dealState;
		this.dealDate = dealDate;
		this.transactor = transactor;
		this.note = note;
		this.tenements = tenements;
	}

	public Integer getCoid() {
		return coid;
	}

	public void setCoid(Integer coid) {
		this.coid = coid;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getDealState() {
		return dealState;
	}

	public void setDealState(String dealState) {
		this.dealState = dealState;
	}

	public Date getDealDate() {
		return dealDate;
	}

	public void setDealDate(Date dealDate) {
		this.dealDate = dealDate;
	}

	public String getTransactor() {
		return transactor;
	}

	public void setTransactor(String transactor) {
		this.transactor = transactor;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public Set<Tenement> getTenements() {
		return tenements;
	}

	public void setTenements(Set<Tenement> tenements) {
		this.tenements = tenements;
	}
/*	
	@Override
	public boolean equals(Object o) {
		if(null == o) {
			return false;
		}
		if(o instanceof Complaint){
			Complaint contrastComplaint = (Complaint)o;
			Integer contrastCoid = contrastComplaint.getCoid();
			Date contrastDate = contrastComplaint.getDate();
			if(this.coid.equals(contrastCoid) && this.date.equals(contrastDate)){
				return true;
			}
		}
		return false;
	}

	@Override
	public int hashCode() {
		return this.coid.hashCode() * this.date.hashCode();
	}
*/
	@Override
	public String toString() {
		String str = this.date.toString() + tenements.toString();
		return str;
	}

	public int compareTo(Object o) {
		Complaint contrastComplaint = (Complaint)o;
		Integer contrastCoid = contrastComplaint.getCoid();
		int orignalId = this.coid.intValue();
		int contrastId = contrastCoid.intValue();
		return BasicUtil.compare(orignalId, contrastId);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((coid == null) ? 0 : coid.hashCode());
		result = prime * result + ((date == null) ? 0 : date.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Complaint))
			return false;
		final Complaint other = (Complaint) obj;
		if (coid == null) {
			if (other.coid != null)
				return false;
		} else if (!coid.equals(other.coid))
			return false;
		if (date == null) {
			if (other.date != null)
				return false;
		} else if (!date.equals(other.date))
			return false;
		return true;
	}
}
